home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / Faximum / FAXclient / bin / fxm < prev    next >
Encoding:
Text File  |  1994-11-16  |  8.4 KB  |  364 lines

  1. #!/bin/sh
  2. #  fxm - a command line interface to Faximum
  3. #
  4. #  Client/Server Release 1.0 - @(#)fxm    1.10  94/11/02
  5. #
  6. # ****************************************************************************
  7. # *                                                                          *
  8. # *                                                                          *
  9. # *                Copyright Faximum Software Inc. 1993-1994                 *
  10. # *                                                                          *
  11. # *       All Rights Reserved. An unpublished and CONFIDENTIAL work.         *
  12. # *     Reproduction, adaptation, or translation without prior written       *
  13. # *   permission is prohibited except as allowed under the copyright laws.   *
  14. # *                                                                          *
  15. # *                                                                          *
  16. # *                        RESTRICTED RIGHTS LEGEND                          *
  17. # *                                                                          *
  18. # *   Use, duplication, or disclosure by the U.S. Government is subject to   *
  19. # *   restrictions as set forth in subparagraph (c) (1) (ii) of the Rights   *
  20. # *   in Technical Data and Computer Software clause in DFARS 252.227-7013.  *
  21. # *   Rights for non-DOD U.S. Government Departments and Agencies are as set *
  22. # *   forth in FAR 52.227-19(c) (1,2).                                       *
  23. # *                                                                          *
  24. # *                          Faximum Software Inc.                           *
  25. # *                      1497 Marine Drive, Suite 300                        *
  26. # *                   West Vancouver, BC, Canada, V7T 1B8                    *
  27. # *                                                                          *
  28. # ****************************************************************************
  29. #
  30. trap "rm -rf /tmp/fxm.$$*" 1 2 15
  31. FAXHOME=${FAXHOME:-/opt/FAXclient}
  32. PATH=$FAXHOME/bin:/bin:/usr/bin
  33. itemno=1
  34. export FAXHOME PATH
  35.  
  36. #
  37. #  The following ought to point to the name of the system which is
  38. #  running the fax server.  On SunFax installations, this is the localhost,
  39. #  on fully networked client/server installations this is usually the
  40. #  alias faxhost although any valid hostname may be used.
  41.  
  42. FAXHOST=localhost
  43. export FAXHOST
  44.  
  45. #
  46. #  Set default values for some parameters:
  47. #
  48. #  Note that if no cover sheet related parameters are specified (such as the
  49. #  to and from names), then the default style will be FAXNCSTYLE.  If such
  50. #  parameters *are* provided, then the default style will be FAXCSTYLE.
  51. #
  52.  
  53. FAXNCSTYLE=${FAXSTYLE:-"No Cover Sheet (Fine)"}
  54. FAXCSTYLE=${FAXSTYLE:-"Default"}
  55. FAXACCOUNT=${FAXACCOUNT:-"Default"}
  56. FAXCLASS=${FAXCLASS:-"Default"}
  57. FAXFROM=${FAXFROM:-"`logname`@`uname -n`"}
  58.  
  59. FILES=no
  60.  
  61. MESSAGE=""
  62. MESSAGEFILE=""
  63. FAXSUBJECT=""
  64. FROMNAME=""
  65. FROMTITLE=""
  66. FROMDEPT=""
  67. TONAME=""
  68. TOTITLE=""
  69. TODEPT=""
  70. COMPANY=""
  71.  
  72. FSTYLE=""
  73. COVERSHEET=no
  74. PHONE=""
  75.  
  76. MYNAME=$0
  77. TF=/tmp/fxm.$$
  78.  
  79. if [ $# -eq 0 ]
  80. then
  81.     more << EOF
  82. Usage:  $0 phone-number [options] files...
  83.  
  84. Options:
  85.     -a    account name (by default: '$FAXACCOUNT')
  86.     -c    class (by default: $FAXCLASS)
  87.     -f    information identifying the sender.  May be repeated up to 3
  88.         times. For example:
  89.         -f "from-name" -f "from-title" -f "from-dept"
  90.     -m msgtext     the text of a message to go on the cover sheet
  91.     -M msgfile  cover sheet message file
  92.     -o    information identifying the recipient (organisation or company).
  93.     -r    subject (i.e re:)
  94.     -s    style (by default: '$FAXCSTYLE' if any of 
  95.     -f, -r, -t, -m, or -M are used, otherwise '$FAXNCSTYLE')
  96.     -t    information identifying the recipient (person). May be repeated up to 3
  97.         times.  For example:
  98.         -t "to-name" -t "to-title" -t "to-department"
  99.  
  100.  
  101. phone-number    the fax number.  If intelligent dialling is enabled and this 
  102.         number does not have four parts (country code (USA=1), area 
  103.         code, exchange, and number), then the country code and (if
  104.         necessary) the area code for your site will be added.
  105.         Must be enclosed in quotation marks if it contains a space.
  106.     
  107. files        the list of attachments.  If a specific style is required for
  108.         an overlay (for example, to arrange for an overlay) then use
  109.         the -S flag.  Each file will be analysed to determine its file
  110.         type.  To force a specific file type use the -T option.
  111.         Note that -S and -T options apply to all remaining attachments 
  112.         until superseded.
  113.  
  114.         If standard input is intended, specify the file name -
  115.  
  116.         If no file names are specified, then standard input is assumed.
  117.  
  118.     -S    attachment-style 
  119.         (i.e. name in the style database)
  120.     -T    attachment-type 
  121.         (one of: ascii, ps, pcl, tiff)
  122.  
  123. Examples:
  124.    $0 555-1212 technote.tif
  125.  
  126.    $0 -t "John Doe" -o "ACME Cement" -f "Jane Smith" -f "Engineering" "1 604 926 8182" file
  127.  
  128. Defaults:
  129.     You may specify default values for the style, account, class, type, and from
  130.     options by setting the following environment variables: FAXSTYLE, 
  131.     FAXACCOUNT, FAXCLASS, and FAXFROM
  132. EOF
  133.     exit
  134. fi
  135.  
  136. > ${TF}.c
  137.  
  138. while [ "$1" != "" ]
  139. do
  140.     case "$1" in
  141.     -a )
  142.         FAXACCOUNT="$2"
  143.         shift
  144.         ;;
  145.  
  146.     -c )
  147.         FAXCLASS="$2"
  148.         shift
  149.         ;;
  150.  
  151.     -f )
  152.         COVERSHEET=yes
  153.         if [ "$FROMNAME" ]
  154.         then
  155.             if [ "$FROMTITLE" ]
  156.             then
  157.             FROMDEPT="$2"
  158.             else
  159.             FROMTITLE="$2"
  160.             fi
  161.         else
  162.             FROMNAME="$2"
  163.         fi
  164.         shift
  165.         ;;
  166.  
  167.     -M )
  168.         COVERSHEET=yes
  169.         if [ -r "$2" ]
  170.         then
  171.             MESSAGEFILE="$2"
  172.         else
  173.             echo "$MYNAME: Error - cannot access file ($2)"
  174.             exit 1
  175.         fi
  176.         shift
  177.         ;;
  178.  
  179.     -m )
  180.         COVERSHEET=yes
  181.         MESSAGE="$2"
  182.         shift
  183.         ;;
  184.  
  185.     -o )
  186.         COVERSHEET=yes
  187.         TOCOMPANY="$2"
  188.         shift
  189.         ;;
  190.  
  191.     -r )
  192.         COVERSHEET=yes
  193.         FAXSUBJECT="$2"
  194.         shift
  195.         ;;
  196.  
  197.     -s )
  198.         FSTYLE="$2"
  199.         shift
  200.         ;;
  201.  
  202.     -t )
  203.         COVERSHEET=yes
  204.         if [ "$TONAME" ]
  205.         then
  206.             if [ "$TOTITLE" ]
  207.             then
  208.             TODEPT="$2"
  209.             else
  210.             TOTITLE="$2"
  211.             fi
  212.         else
  213.             TONAME="$2"
  214.         fi
  215.         shift
  216.         ;;
  217.  
  218.     -S )
  219.         if [ ! "$PHONE" ]
  220.         then
  221.             echo "$MYNAME: Error - no phone number specified"
  222.             exit 1
  223.         fi
  224.         STYLE=$2
  225.         shift
  226.         ;;
  227.  
  228.     -T )
  229.         if [ "$PHONE" = "" ]
  230.         then
  231.             echo "$MYNAME: Error - no phone number specified"
  232.             rm -rf ${TF}*
  233.             exit 1
  234.         fi
  235.         case $2 in
  236.             a | ascii | A | ASCII )
  237.                 TYPE=ASCII
  238.                 ;;
  239.             tif | tiff | TIF | TIFF )
  240.                 TYPE=TIFF
  241.                 ;;
  242.             ps | PS | PostScript | postscript | POSTSCRIPT )
  243.                 TYPE=PostScript
  244.                 ;;
  245.             pcl | PCL | pcl-? | PCL-? )
  246.                 TYPE=PCL
  247.                 ;;
  248.             * )
  249.                 echo "$MYNAME: Error - bad file type ($2)"
  250.                 rm -rf ${TF}*
  251.                 exit 1
  252.                 ;;
  253.         esac
  254.         shift
  255.         ;;
  256.  
  257.     * )
  258.         if [ "$PHONE" = "" ]
  259.         then
  260.             PHONE="$1"
  261.         elif [ "$1" = "-" ]
  262.         then
  263.             # attachment is standard input
  264.             FILES=yes
  265.             cat > ${TF}.${itemno}
  266.             echo "file_name${itemno} = /tmp/fxm.$$.${itemno}" >> ${TF}.c
  267.             if [ "$STYLE" ]
  268.             then
  269.                 echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
  270.             fi
  271.             if [ "$TYPE" ]
  272.             then
  273.                 echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
  274.             fi
  275.             echo "file_delete${itemno} = yes" >> ${TF}.c
  276.             itemno=`expr $itemno + 1`
  277.         elif [ -r "$1" ]
  278.         then
  279.             # we have an attachment
  280.             #
  281.             FILES=yes
  282.             echo "file_name${itemno} = $1" >> ${TF}.c
  283.             if [ "$STYLE" ]
  284.             then
  285.                 echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
  286.             fi
  287.             if [ "$TYPE" ]
  288.             then
  289.                 echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
  290.             fi
  291.             itemno=`expr $itemno + 1`
  292.         else
  293.             echo "$MYNAME: Error - cannot access file ($1)"
  294.             rm -rf ${TF}*
  295.             exit 1
  296.         fi
  297.         ;;
  298.     esac
  299.     shift
  300. done
  301.  
  302. if [ $FILES = no ]
  303. then
  304.     # file must come from standard input
  305.     cat > ${TF}.${itemno}
  306.     echo "file_name${itemno} = /tmp/fxm.$$.${itemno}" >> ${TF}.c
  307.     if [ "$STYLE" ]
  308.     then
  309.         echo "file_style${itemno} = ${STYLE}" >> ${TF}.c
  310.     fi
  311.     if [ "$TYPE" ]
  312.     then
  313.         echo "file_type${itemno} = ${TYPE}" >> ${TF}.c
  314.     fi
  315.     echo "file_delete${itemno} = yes" >> ${TF}.c
  316.     itemno=`expr $itemno + 1`
  317. fi
  318.  
  319. if [ "$FSTYLE" ]
  320. then
  321.     FAXSTYLE="$FSTYLE"
  322. else
  323.     if [ $COVERSHEET = "yes" ]
  324.     then
  325.     FAXSTYLE="$FAXCSTYLE"
  326.     else
  327.     FAXSTYLE="$FAXNCSTYLE"
  328.     fi
  329. fi
  330.  
  331. if [ ! "$PHONE" ]
  332. then
  333.     echo "$MYNAME: Error - Missing phone number."
  334.     rm -rf ${TF}*
  335.     exit 1
  336. fi
  337.  
  338. #
  339. # Put the rest of the parameters into the command file
  340. #
  341.  
  342. cat >> ${TF}.c <<- EOF
  343.     dest_name1 = "$TONAME"
  344.     dest_title1 = "$TOTITLE"
  345.     dest_dept1 = "$TODEPT"
  346.     dest_company1 = "$TOCOMPANY"
  347.     dest_fax1 = "$PHONE"
  348.     class = "$FAXCLASS"
  349.     style = "$FAXSTYLE"
  350.     account = "$FAXACCOUNT"
  351.     from_name = "$FROMNAME"
  352.     from_title = "$FROMTITLE"
  353.     from_dept = "$FROMDEPT"
  354.     subject = "$FAXSUBJECT"
  355.     message = "$MESSAGE"
  356.     messagefile = "$MESSAGEFILE"
  357. EOF
  358.  
  359. #
  360. #  Send the command file off to submitfax...
  361. #
  362. ${FAXHOME}/lib/submitfax ${TF}.c
  363. rm -f ${TF}.c
  364.